package com.example.websockettest.webSocket.service;

import com.example.websockettest.webSocket.entity.GameUser;
import com.example.websockettest.webSocket.mapper.GameUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserService {
    @Autowired
    private GameUserMapper gameUserMapper;

    public boolean register(GameUser user){
       GameUser existUser=gameUserMapper.selectGameUserByUser(user.getUser());
       if(existUser!=null){
           return false;
       }
       gameUserMapper.insertGameUser(user);
       return true;
    }
    public boolean login(GameUser user){
        GameUser existUser=gameUserMapper.selectGameUserByUser(user.getUser());
        if(existUser==null){
            return false;
        }
        return existUser.getPassword().equals(user.getPassword());
    }
}

